# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=caddy
pkgver=2.7.6
pkgrel=0
pkgdesc="Fast, multi-platform web server with automatic HTTPS"
url="https://caddyserver.com/"
license="Apache-2.0"
arch="all"
depends="ca-certificates"
makedepends="go"
subpackages="$pkgname-openrc"
pkgusers="$pkgname"
pkggroups="$pkgname"
install="$pkgname.pre-install"
source="https://github.com/caddyserver/caddy/archive/v$pkgver/caddy-$pkgver.tar.gz
	$pkgname.initd
	Caddyfile
	"
options="net" # for downloading Go modules

export CGO_ENABLED=0
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -o bin/caddy ./cmd/caddy
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/caddy -t "$pkgdir"/usr/sbin/

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/Caddyfile -t "$pkgdir"/etc/$pkgname/
}

sha512sums="
ef0cb6fd7f6f2a296290b4bb520300e043ad31cc612e734632ffa25cdaa23fd7d601ac4ceaa1c76285d54a07ee773360f795103ef3c2ec79516a4f18a5e844b5  caddy-2.7.6.tar.gz
5dec305ee9b51d59a25d2c9c02d6d4e60bfc83ce3329f750f3c7d59ff7b5a4e844b0d999fa989cdaa37dbf086fefe82aec9351b08620fe8da9818ececc1436f0  caddy.initd
d3110dd79f7d5e602a34d42569104dc97603994e42daf5f6b105303a3d034b52b91ef5fb156d5bf7b7a3a58ec0aeff58afc402618d0555af053771952a866f76  Caddyfile
"
